package com.immunology.database.transformers;

import java.sql.ResultSet;
import java.sql.SQLException;

import org.apache.log4j.Logger;

import com.immunology.core.BaseTransformer;
import com.immunology.database.DbColumns;
import com.immunology.model.MedicineCard;

public class MedicineCardTransformer extends BaseTransformer<MedicineCard> {
	private static final Logger LOG = Logger
			.getLogger(MedicineCardTransformer.class);

	@Override
	public MedicineCard transformTo(ResultSet resultSet) {
		MedicineCard medicineCard = new MedicineCard();
		try {
			medicineCard.setId(resultSet.getInt(DbColumns.FIRST_COLUMN));
			medicineCard
					.setPatientId(resultSet.getInt(DbColumns.SECOND_COLUMN));
			medicineCard.setCreationDate(resultSet
					.getDate(DbColumns.THIRD_COLUMN));
			medicineCard.setOtherPatientInfo(resultSet
					.getString(DbColumns.FOURTH_COLUMN));
		} catch (SQLException e) {
			LOG.error("Can't create ComplaintTransformer object:", e);
		}
		return medicineCard;
	}

}
